<template>
  <div class="app-container">
    <div class="mod-result-table">
      <!-- <HTable
        ref="table"
        :tableData="tableData"
        :columnConfigs="columnConfigs"
        @selection-change="handleSelectionChange"
        :selectable="false"
        orderable
        :height="666"
        v-loading="loading"
        :pages="pagination"
        @page-change="handlePageChange"
        @size-change="handleSizeChange"
      >
        <template slot-scope="{ row }">
          <template v-if="row.name == 'action'">
            <el-button
              type="text"
              size="small"
              icon="el-icon-edit"
              >详情</el-button
            >
          </template>
        </template>
      </HTable> -->
    </div>
  </div>
</template>

<script>
import table from "@/mixins/commontable";
import { columnConfigs } from "./columnConfigs.js";
import { tearr19kolist } from "./data1.js";
// import { getkoidList } from "@/api/yybl/wstmodel";
import { playerobj7 } from "./alldata7.js";
import { playerobj9 } from "./alldata9.js";
import { playerobj11 } from "./alldata11.js";
import { playerobj19 } from "./alldata19.js";
import { queryid } from "./ids";
import zuihou from "./zuizhong";
export default {
  components: {},
  mixins: [table], //表格的混入，主要包括表格上通用的方法和数据，比如查询，重置，分页这些功能
  props: {},
  data() {
    return {
      columnConfigs,
      dialogVisible1: false,
      editFlag: false,
      curRow: {},
      oklist: [],
      nolist: [],
    };
  },
  watch: {},
  computed: {},
  methods: {
    getarr9vallist() {
      // console.log(arr9);
      // console.log(arr9.length);
      // console.log(arr9kolist.length);
      let idvalstop = [];
      let idvalfail = [];
      let idval100 = [];
      let idval65 = [];
      let idval35 = [];
      let idval0 = [];
      let objkomap = [];
      let starttotal = [];
      let failPlustotal = [];
      // const objko = getrandomlist(tesaijuObj, 100);
      // const objko = playerobj7;
      ////te14 8 ao13 5 mawei 20 9 sai25 4
      //            7 4       15 5    16 3
      //                      7  4    9  3
      //   6  3    6  1           6  2       7  2 
      const objko = playerobj9; //te6 0 ao5 2  mawei 3 2
      // te22 8 ao 7 4 mawei 16 8 ailun 21 9 sai11 11
      // 7 2       4 3       10 5       10 7 
      // 13 6          2 1           4 3          10 2
      // const objko = playerobj11; //te10-12 4 ao9-10 3 mawei 6-8 2  ailun9-? 4
      ////te23-27 10 ao21-24 10 mawei 17-21 9  ailun21-25? 11
      ////te27-11 ao13 5 mawei 10 4  ailun11? 7 sai7 5
      // 9 3       8 5       9 5       9  4   9 9
      // const objko = playerobj11; //te1 4 ao11 9
      //te19 11 ao29 8 mawei13 6 ailun22 10 
      //te8 11   ao25 8 mawei10 6 ailun10 10
      ////te1 5 ao13 5 mawei7 4 ailun8 6
      // zuihou([27], [10]);1 小特11 1.53
      // zuihou([21], [10]);2
      // zuihou([19], [9]);3
      // zuihou([20], [11]);4
      // zuihou([20], [8]);1
      // zuihou([6], [4]);4
      // zuihou([14], [8]);3
      // zuihou([20], [9]);2
      // zuihou([14], [6]);4 
      // zuihou([13], [4]);2 奥沙 7  1.48
      // zuihou([20], [6]);1 麻薯 7  1.48
      // zuihou([19], [8]);3
      // zuihou([19], [11]);4
      // zuihou([29], [8]);1
      // zuihou([13], [6]);2
      // zuihou([22], [10]);3
      for (const key in objko) {
        objkomap.push(key);
        if (Object.hasOwnProperty.call(objko, key)) {
          const res = objko[key];
          if (res && res.length > 0) {
            // data = [...data, ...res];
            if (res.length > 0) {
              // 获取小特的输赢情况
              console.log(res);
              const arr = res.map((i) => {
                if (i.PlayerId == queryid) {
                  return i.Points > i.VsPoints;
                } else if (i.VsPlayerId == queryid) {
                  return i.VsPoints > i.Points;
                } else {
                  return "aaaa";
                }
              });
              console.log(arr);
              const list = arr
                .map((i, index) => {
                  if (index == 1) {
                    const a = arr[index - 1];
                    if (a == i && i) {
                      return "ok1";
                    } else {
                      return "fail";
                    }
                  } else if (index > 1) {
                    const b = arr[index - 1];
                    const a = arr[index - 2];
                    if (a == true && b == true) {
                      return "truestop"; //no
                    } else if (a == true && b == false) {
                      return "falsestop"; //no
                    } else if (a == false && b == true && i == true) {
                      return "ok2"; //yes
                    } else if (a == false && b == true && i == false) {
                      return "fail"; //yes
                    } else if (a == false && b == false && i == true) {
                      return "start"; //no
                    } else if (a == false && b == false && i == false) {
                      return "failPlus"; //no
                    }
                  } else {
                    return "begin";
                  }
                })
                .filter((j) => j != "begin");
              const oklist = list.filter(
                (i) => i == "ok" || i == "ok1" || i == "ok2"
              );
              const faillist = list.filter((i) => i == "fail");
              const truestoplist = list.filter((i) => i == "truestop");
              const falsestoplist = list.filter((i) => i == "falsestop");
              const startlist = list.filter((i) => i == "start");
              const failPluslist = list.filter((i) => i == "failPlus");
              // console.log(oklist, "ok");
              // console.log(faillist, "fail");
              // console.log(truestoplist, "truestop");
              // console.log(falsestoplist, "falsestop");
              // const lv = oklist.length / (faillist.length + oklist.length);
              // console.log(lv, "oklv");
              console.log(startlist, "start");
              if (failPluslist.length < 2) {
                starttotal = [...starttotal, ...startlist];
              }
              console.log(failPluslist, "failPlus");
              if (failPluslist.length > 0) {
                failPlustotal.push("failPlus");
                if (failPluslist.length > 1) {
                  failPlustotal.push("failPlus");
                }
              }
              let startlv = 0;
              if (startlist.length == 0 && failPluslist.length > 0) {
                startlv = "fail";
              }
              if (startlist.length == 0 && failPluslist.length == 0) {
                startlv = "stop";
              }
              if (startlist.length > 0) {
                startlv =
                  startlist.length / (failPluslist.length + startlist.length);
              }

              console.log(startlv, "oklv");
              if (startlv == "stop") {
                idvalstop.push(key);
              } else if (startlv == "fail") {
                // console.log(lv, key);
                idvalfail.push(key);
              } else {
                if (startlv == 1) {
                  idval100.push(key);
                } else if (startlv > 0.65) {
                  // console.log(lv, key);
                  idval65.push(key);
                } else if (startlv > 0.35) {
                  // console.log(lv, key);
                  idval35.push(key);
                } else if (startlv > 0) {
                  // console.log(lv, key);
                  idval0.push(key);
                }
              }
              // else {
              //   idvalno.push(key);
              // }
              // if (lv > 0.65) {
              //   idval.push(key);
              // } else if (lv < 0.65 && lv > 0.35) {
              //   // console.log(lv, key);
              //   idvalto.push(key);
              // } else {
              //   idvalno.push(key);
              // }
            }
          }
        }
      }
      console.log(idval100, "1");
      console.log(idval65, "0.65");
      console.log(idval35, "0.35");
      console.log(idval0, "0");
      console.log(idvalfail, "fail");
      console.log(idvalstop, "stop");
      console.log(starttotal, "starttotal");
      console.log(failPlustotal, "failPlustotal");
      console.log(objkomap);
    },
    async getkoidList() {
      let data = [];
      let idval = [];
      let idvalto = [];
      // for (let index = 0; index < 1; index++) {
      //   this.getarr9vallist();
      // }
      this.getarr9vallist();
      // console.log(this.oklist);

      // console.log(this.nolist);
      // zuihou(this.oklist, this.nolist);
      // this.getarr11vallist();
      // console.log(vallist);
      // console.log(idvaltolist);
      // arr9kolist.splice(0, 39);
      // console.log(arr9kolist.length);
      // console.log(arr11kolist.length);
      // const koidlist = arr11kolist.slice(0, 0);
      // let obj = {};
      // for (let index = 0; index < koidlist.length; index++) {
      //   let params = {
      //     koid: koidlist[index],
      //   };
      //   try {
      //     const res = await getkoidList(params);
      //     if (data.length < 2390) {
      //       if (res && res.length > 0) {
      //         // data = [...data, ...res];
      //         if (res.length > 0) {
      //           // 获取res中连胜的情况
      //           obj[params.koid] = res;
      //           // res.splice(11);
      //           // const arr = res.map((i) => {
      //           //   if (
      //           //     (i.Points || i.Points === 0) &&
      //           //     (i.VsPoints || i.VsPoints === 0)
      //           //   ) {
      //           //     return i.Points > i.VsPoints;
      //           //   } else {
      //           //     return "aaaaa";
      //           //   }
      //           // });
      //           // // console.log(arr);
      //           // const list = arr
      //           //   .map((i, index) => {
      //           //     if (index > 0) {
      //           //       const a = arr[index - 1];
      //           //       if (a == i) {
      //           //         return "ok";
      //           //       } else {
      //           //         return "fail";
      //           //       }
      //           //     } else {
      //           //       return "begin";
      //           //     }
      //           //   })
      //           //   .filter((j) => j != "begin");
      //           // // console.log(list);
      //           // const oklist = list.filter((i) => i == "ok");
      //           // const lv = oklist.length / list.length;
      //           // // console.log(lv);
      //           // if (lv > 0.65) {
      //           //   idval.push(params.koid);
      //           // } else if (lv < 0.45) {
      //           //   idvalto.push(params.koid);
      //           // }
      //         }
      //       } else {
      //         console.log(res, index);
      //       }
      //     } else {
      //       console.log(index);
      //     }
      //   } catch (error) {
      //     console.log(error);
      //   }
      // }
      // console.log(obj, "koidjs");
    },
  },
  created() {
    this.getkoidList();
  },
  mounted() {},
};
</script>
<style lang="scss" scoped>
.queryform {
  ::v-deep .el-form {
    display: flex;
    flex-wrap: wrap;

    .el-form-item {
      max-width: 33.3%;
      flex-grow: 1;
      flex-shrink: 1;
      flex-basis: 33.3%;
    }

    // .el-form-item:nth-child(7) {
    //   max-width: 100%;
    //   flex-basis: 100%;
    //   display: flex;
    //   justify-content: end;
    // }
  }
}
::v-deep .el-form-item__content {
  .el-date-editor.el-input {
    width: 100%;
  }
}
::v-deep .el-button {
  .el-icon-edit + span {
    margin-left: 0px;
  }
  .el-icon-delete + span {
    margin-left: 0px;
  }
}
::v-deep .el-dialog {
  min-width: 640px;
  .el-dialog__header {
    border-bottom: 1px solid #e8e8e8;
  }
  .el-dialog__footer {
    border-top: 1px solid #e8e8e8;
  }
}
.addDialog {
  .el-dialog {
    min-width: 640px;
  }

  .el-form {
    .el-form-item.slider {
      width: 100%;
    }
  }
}
</style>
